package com.yjhb.android.sbz.activity;

import android.content.Intent;

import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;
import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.activity.rule.RuleReport2Activity;
import com.yjhb.android.sbz.fragment.tipoff.TipOffFragment;
import com.yjhb.android.sbz.tool.MsgReadTool;
import com.yjhb.android.sbz.tool.Tool;
import com.jojo.android.zxlib.adapter.FragmentAdapter;
import com.jojo.android.zxlib.base.BaseFragment;
import com.jojo.android.zxlib.base.mvp.BasePresenter;
import com.jojo.android.zxlib.tool.ZxActivityTool;
import com.tencent.qcloud.tim.uikit.UnReadManager;
import com.tencent.qcloud.tim.uikit.config.SysUserConfig;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 创建者 zx
 * 创建时间 2020/12/21 18:01
 */
public class TipOffActivity extends BaseActivity {
    private final String TAG = "TipOffActivity";
    @BindView(R.id.tabLayout)
    TabLayout tabLayout;
    @BindView(R.id.viewpager)
    ViewPager viewpager;


    List<BaseFragment> fragments = new ArrayList<>();
    TipOffFragment tipOffFragment1;
    TipOffFragment tipOffFragment2;
    FragmentAdapter fragmentAdapter;

    MsgReadTool readTool;

    @Override
    protected BasePresenter initPresenter() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_tip_off;
    }

    @Override
    protected void initUI() {
        fragments.clear();
        fragments.add(tipOffFragment1 = new TipOffFragment());
        tipOffFragment1.setLaunch(false);
        fragments.add(tipOffFragment2 = new TipOffFragment());
        tipOffFragment2.setLaunch(true);
        viewpager.setAdapter(fragmentAdapter = new FragmentAdapter(getSupportFragmentManager(), fragments));
        tabLayout.setupWithViewPager(viewpager);
        tabLayout.getTabAt(0).setText("举报我的");
        tabLayout.getTabAt(1).setText("我举报的");
        readTool = new MsgReadTool();
        readTool.loadSystemNotice(SysUserConfig.REPORT_NOTICE.getId());
        UnReadManager.getInstance().setUnreadReport(0);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onDestroy() {
        if (readTool != null) {
            readTool.destroyChat();
        }
        super.onDestroy();
    }

    @Override
    protected void regEvent() {

    }

    @OnClick(R.id.back)
    void back() {
        finish();
    }

    @OnClick(R.id.title_right_tv)
    void title_right_tv() {
        ZxActivityTool.skipActivity(this, RuleReport2Activity.class);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Tool.PictureSelectedSuccessSendMsg(requestCode, resultCode, data);
    }

}
